import 'package:flutter/material.dart';

class ShopList extends StatelessWidget {
  ShopList({super.key});

  final Map goods = {
    "createTime": "2024-08-15 21:49:48",
    "orderState": 2,
    "image":
        "https://yanxuan-item.nosdn.127.net/a09de222ed32efa8ffe359b1d5780574.jpg",
    "name": "茶水分离杯耐热隔热玻璃杯茶水分离杯耐热隔热玻璃杯",
    "totalNum": 2,
    "curPrice": 119.5,
    "totalMoney": 119.5,
    "attrsText": "规格:白色240ml",
  };

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(10),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.end,
        children: [
          // 顶部
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(goods['createTime']),
              Text(
                goods['orderState'] == 2 ? '待发货' : '已发货',
                style: TextStyle(color: Colors.orange),
              ),
            ],
          ),
          // 中间部分
          Padding(
            padding: EdgeInsets.only(top: 10, bottom: 10),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                // 中间--左侧图片部分
                Image.network(goods['image'], width: 110, height: 110),
                // 中间--右侧
                Expanded(
                  flex: 1,
                  child: Padding(
                    padding: EdgeInsets.only(left: 10),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Row(
                          children: [
                            Expanded(child: Text(goods['name'])),
                            SizedBox(width: 10),
                            Text('x${goods['totalNum']}'),
                          ],
                        ),
                        // 中间第二行
                        Container(
                          margin: EdgeInsets.only(top: 10, bottom: 10),
                          padding: EdgeInsets.all(5),
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(5),
                            color: Colors.grey,
                          ),
                          child: Text(
                            goods['attrsText'],
                            style: TextStyle(color: Colors.white, fontSize: 12),
                          ),
                        ),
                        // 第三行价格
                        Text('￥${goods['curPrice']}'),
                      ],
                    ),
                  ),
                ),
              ],
            ),
          ),
          Text('合计：${goods['curPrice'] * goods['totalNum']}'),
          const SizedBox(height: 10),
          // 按钮
          Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              ElevatedButton(onPressed: () {}, child: Text('取消订单')),
              SizedBox(width: 10),
              ElevatedButton(onPressed: () {}, child: Text('再次购买')),
            ],
          ),
        ],
      ),
    );
  }
}
